package LeetCode;

/**
 * @Author: Dijah
 * @Date: 2022/12/30 15:32
 * @Desc: 错过的数字
 */
public class missingNumber {

    public static int missingNum(int [] nums){

        int n = nums.length;
        long except = (0 + n) * (n + 1)/2;
        long sum = 0L;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
        }
        return (int)(except-sum);
    }

    public static void main(String[] args) {
        int [] nums = {0,3,1,4};
        int i = missingNum(nums);
        System.out.println(i);
    }
}
